import Vue from 'vue'
import App from './App.vue'
import router from '@/router'


//element-ui按需引入：
import { 
  Popover,
  Pagination,
  Button,
  Form,
  FormItem,
  Tag, 
  Dialog,
  Select, 
  MessageBox,
  Message , 
  Carousel,
  Image,
  Card,
  Input,
  Timeline,
  TimelineItem,
  CarouselItem,
  Avatar,
  Dropdown,
  DropdownItem,
  Divider,
  Badge,
  Scrollbar,
  Upload,
  Row,
  Col
} from 'element-ui';
//自定义组件（块）
import CustomBlock from '@/components/CustomBlock'
Vue.component('CustomBlock', CustomBlock);
//全局组件轮播图
import MyCarousel from '@/components/MyCarousel'
import MySideBar from '@/components/MySideBar'
import MyEmoji from '@/components/Emoji'
Vue.component(MyEmoji.name,MyEmoji);
Vue.component(MyCarousel.name, MyCarousel);
//element-ui组件
Vue.component(Scrollbar.name, Scrollbar);
Vue.component(Carousel.name, Carousel);
Vue.component(Popover.name, Popover);
Vue.component(CarouselItem.name,CarouselItem)
Vue.component(Button.name,Button)
Vue.component(Image.name,Image)
Vue.component(Card.name,Card)
Vue.component(Avatar.name,Avatar)
Vue.component(Input.name,Input)
Vue.component(Timeline.name,Timeline)
Vue.component(TimelineItem.name,TimelineItem)
Vue.component(Pagination.name,Pagination)
Vue.component(Tag.name,Tag)
Vue.component(Dropdown.name,Dropdown)
Vue.component(DropdownItem.name,DropdownItem)
Vue.component(Divider.name,Divider)
Vue.component(Dialog.name,Dialog)
Vue.component(Form.name,Form)
Vue.component(FormItem.name,FormItem)
Vue.component(Upload.name,Upload)
Vue.component(Badge.name,Badge)
Vue.component(Row.name,Row)
Vue.component(Col.name,Col)

//方式二：挂在vue原型上，需要提前引入
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$message = Message;
Vue.prototype.$confirm = MessageBox.confirm;

//echarts
import * as echarts from "echarts";
Vue.prototype.$echarts = echarts
// //侧边栏组件
Vue.component(MySideBar.name,MySideBar)
//IM聊天
import Chat from 'vue-beautiful-chat'
Vue.use(Chat)
//音乐播放器
//
Vue.config.warnHandler = function (msg, vm, trace) {
  console.warn(msg);
}
Vue.config.productionTip = false;

//表单验证
import "@/plugins/validate"

//md富文本编辑器渲染
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
import Prism from 'prismjs';
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';
import createTipPlugin from '@kangc/v-md-editor/lib/plugins/tip/index';
import createEmojiPlugin from '@kangc/v-md-editor/lib/plugins/emoji/index';
import createTodoListPlugin from '@kangc/v-md-editor/lib/plugins/todo-list/index';
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
import createAlignPlugin from '@kangc/v-md-editor/lib/plugins/align';
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
import '@kangc/v-md-editor/lib/plugins/todo-list/todo-list.css';
import '@kangc/v-md-editor/lib/plugins/emoji/emoji.css';
import '@kangc/v-md-editor/lib/style/preview-html.css';
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';

VMdPreview.use(vuepressTheme, {
  Prism,
  config: {
    toc: {
      includeLevel: [1, 2, 3, 4, 5],
    },
  },
}).use(createLineNumbertPlugin()).use(createTipPlugin()).use(createEmojiPlugin()).use(createTodoListPlugin()).use(createCopyCodePlugin())
.use(createAlignPlugin());

Vue.use(VMdPreview);

//引入相关API请求
import API from '@/api'
//组件实例的原型指向的是Vue.prototype
//任意组件都可以使用API相关的接口
Vue.prototype.$API = API;
import store from './store'

new Vue({
  render: h => h(App),
  //配置全局事件总线
  beforeCreate(){
    Vue.prototype.$bus = this
  },
  router,
  store
}).$mount('#app')
















